<style>
form{background:none; padding:0px; border:0px;}
</style>

<?php
	echo sprintf(__("Visit %s"),$html->link(__("Facebook doc"),"http://developers.facebook.com/docs/reference/api/user"));
	echo $form->create("FacebookConfig",array("url"=>"/".$this->params['url']['url']));
?>
<table>
	<tr>
		<th>
			<?php echo  __("Field")?>
		</th>
		<th>
			<?php echo __("Facebook field")?>
		</th>
	</tr>
	<?php foreach($userFields as $userField => $label){?>
		<tr>
			<td>
				<?php echo $form->input("FacebookConfig.$userField",array("type"=>"checkbox","class"=>"user_field",'label'=>$label,'id'=>"user_field_$userField"))?>
			</td>
			<td>
				<?php echo $form->input("FacebookConfig.$userField",array("type"=>"select","class"=>"fb_field",'label'=>"Facebook fields","options"=>$facebookFields,'id'=>"fb_box_$userField",'empty'=>__("-Select-")))?>
			</td>
		</tr>
	<?php }?>
</table>
<?php 
	echo $form->end(__("Submit"));
?>

<script>
	$(document).ready(function(){
		$('.user_field').each(function(){
				var fieldName = field = $(this).attr('id').replace(/^user_field_/,'');
				console.log(fieldName);
				$(this).change(function(){
						
						setFbFieldStatus(this,fieldName);
					});
				setFbFieldStatus(this,fieldName);
			});	
	});
	
	function setFbFieldStatus(dom,field)
	{
		var disabled = true;
		if($(dom).attr('checked')== true)
		{
			var disabled = false;
		}
		$('#fb_box_'+field).attr('disabled',disabled);
	}
</script>